package com.yty.demo._4_oop.implements_demo;

/**
 * @author: yangtaoyao
 * @time: 2020/1/10 10:14
 * @description: 接口应用举例 2
 */
public class Man extends Creator implements Runner,Swimmer {
    @Override
    public void run() {
        System.out.println("Man.run()");
    }

    @Override
    public void swim() {
        System.out.println("Man.swim()");
    }

    public void eat(){
        System.out.println("Man.eat()");
    }
}

class Creator{
    public void eat(){
        System.out.println("Creator.eat()");
    }
}

interface Runner{
    void run();
}
interface Swimmer{
    void swim();
}

abstract class impleAbstractClass implements Runner{
}

/**
 * 接口与实现类之间的多态
 */
class Test{
    public void m1(Runner r){
        r.run();
    }

    public void m2(Swimmer s){
        s.swim();
    }

    public void m3(Creator c){
        c.eat();
    }

    public static void main(String[] args) {
        Man man=new Man();
        //Runner man=new Man();//2与3 语法报错无法通过编译
        Test test=new Test();
        test.m1(man);//1
        test.m2(man);//2
        test.m3(man);//3
    }
}